package com.csust.zerocode.service;

import com.csust.zerocode.model.dto.app.AppAddRequest;
import com.csust.zerocode.model.dto.app.AppQueryRequest;
import com.csust.zerocode.model.entity.App;
import com.csust.zerocode.model.entity.User;
import com.csust.zerocode.model.vo.app.AppVO;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.service.IService;
import reactor.core.publisher.Flux;

import java.util.List;

/**
 *  服务层。
 *
 * @author 钰玟
 */
public interface AppService extends IService<App> {
    /**
     * @param app  app
     * @return appVO
     */
    AppVO getAppVO(App app);

    /**
     * 获取查询包装类
     * @param appQueryRequest appQueryRequest
     * @return QueryWrapper
     */
    QueryWrapper getQueryWrapper(AppQueryRequest appQueryRequest);
    /**
     * 根据实体类列表得到AppVO列表
     * @param appList appList
     * @return AppVO列表
     */
    List<AppVO> getAppVOList(List<App> appList);

    /**
     *  聊天生成代码
     * @param appId 应用ID
     * @param message  用户提示词
     * @param loginUser 当前用户
     * @return Flux<String> 流式响应片段
     */
    Flux<String> chatToGenCode(Long appId, String message, User loginUser);

    /**
     * 创建应用
     * @param appAddRequest 创建应用参数
     * @param loginUser 当前用户
     * @return
     */
    Long createApp(AppAddRequest appAddRequest, User loginUser);

    /**
     * 部署应用
     * @param appId 部署应用ID
     * @param loginUser 当前用户
     * @return 部署路径
     */
    String deployApp(Long appId, User loginUser);
    /**
     * 异步生成应用截图并更新封面
     *
     * @param appId  应用ID
     * @param appUrl 应用访问URL
     */
    void generateAppScreenshotAsync(Long appId, String appUrl);
}